#!/usr/bin/env pytho      
# -*- coding: utf-8 -*-
# @Author  : junpeng_chen
# @Time    : 2023/7/28 19:46
# @File    : order_by_recognition_test.py
# @annotation    : 测试

import unittest
from utils.chatglm_utils import ChatGLMUtils
from modules.order_by_recognition import OrderByRecognition

order_by_reg = OrderByRecognition()


class TestMeasureRecognition(unittest.TestCase):
    def test_order_by(self):
        question = ""
        sel = [{
            'id': 'AUGMENTED_DATASET_LEVEL.I8a8ae5ca0178549554951b9501785cefe3f00058.MT_DIMENSION_FIELD.3943e92bed35dac104c3a1f2b2195a5e-LEVEL-1667896190875',
            'name': '年', 'type': 'STRING', 'timeLevel': 'year', 'member_amount': 1}, {
            'id': 'AUGMENTED_DATASET_LEVEL.I8a8ae5ca0178549554951b9501785cefe3f00058.MT_DIMENSION_FIELD.affebb66d15867660b4dcd4712c9a7d9-LEVEL-1667896197688',
            'name': '月', 'type': 'STRING', 'timeLevel': 'month', 'member_amount': 0}, {
            'id': 'AUGMENTED_DATASET_MEASURE.I8a8ae5ca0178549554951b9501785cefe3f00058.MT_METRICS.I8a8ae5ca0178549554951b9501785d983aaa005e',
            'name': '合同金额', 'type': 'DOUBLE', 'timeLevel': '', 'member_amount': 0}]
        measure = [
            'AUGMENTED_DATASET_MEASURE.I8a8ae5ca0178549554951b9501785cefe3f00058.MT_METRICS.I8a8ae5ca0178549554951b9501785d983aaa005e']
        having = []
        res = order_by_reg.order_by(question, sel, having, measure)

        ans = [['AUGMENTED_DATASET_LEVEL.I8a8ae5ca0178549554951b9501785cefe3f00058.MT_DIMENSION_FIELD.affebb66d15867660b4dcd4712c9a7d9-LEVEL-1667896197688','ASC','COL','NAME','月']]
        self.assertEqual(res['order_by'],ans)

